<?php

namespace catchAdmin\pc\model;

class WechatUserBalance extends \catchAdmin\model\WechatUserBalance
{


    public $name = 'wechat_user_balance';


    public function indexData($param)
    {
        $app = $this
            ->with(['wechatUser']);

        return $this->indexDataPcCC($param, $app);
    }


    public function indexByCompanyId($param)
    {
        $user_company_msg = (new \catchAdmin\model\UserCompany())
            ->where('id', $param['company_id'])
            ->find();

        $app = $this
            ->where('balance_type', 1)
            ->where('wechat_user_id', $user_company_msg['wechat_user_id'] ?? 0)
            ->with(['wechatUser']);

        return $this->indexDataPcCC($param, $app);
    }


    public function readData($param)
    {
        return $this
            ->where("id", $param['id'])
            ->find();
    }


    /**
     * 提现
     */
    public function withdrawIncome($param)
    {
        $app = $this
            ->where('balance_type_2', 302)
            ->with(['wechatUser']);

        return $this->indexDataPcCC($param, $app);
    }


}
